﻿<style type="text/css">
<!--	
	@import url('<?php echo base_url(); ?>css/admin/thickbox.css');
-->
</style>
<div id="pagecontent">
<table width="100%" border="0" cellpadding="0">
  <tr>
<!--  <form action="dosearch" method="post" name="search_article" target="_self">
    <td><div style="float:left;  padding-left:50px;"><input id="search" name="search" type="text" size="20" maxlength="30" value=""/></div></td>
	<td align="left" valign="middle"><div style="cursor:pointer; float:left; vertical-align:middle"><select id=="article_category" name="article_category"><option value=0>----- Tất cả -----</option><option value=5>Về Nam Long</option><option value=6>Phân xướng/Máy móc</option><option value=11>Công ty Nam Long</option><option value=12>Tin tổng hợp</option>	<option value=9>Ẩm thực / Mẹo vặt</option><option value=13>Kiến thức hạt điều</option></select></div></td>
	<td width="100" align="left">&nbsp;<input name="searchbutton" type="submit" value="Tìm kiếm" style="font-weight: bold;font-size: 8pt;color:#FF0066;" onclick="change_action()"/></td></form>-->
    <td width="450"><div style="cursor:pointer; float:right; font-weight:bold; color:#FF0066;" onclick="location.href='<?php echo base_url().index_page(); ?>/adminpage/cpanel/add_article/'"><span style="text-decoration:overline"><?php echo $this->lang->line('action_new'); ?></span> <img  src="<?php echo base_url(); ?>images/icon-32-new.png" align="absmiddle"/></div></td>
  </tr>
</table>



<?php 
	if($this->session->flashdata('message'))
	{
?>
<div id="sponsorAdDiv" style="visibility:hidden">
<table width="305px" height="50px" bgcolor="#FF0000"><tr><td>
<table width="300px" height="45px" bgcolor="#FFFFCC"><tr><td align="center" valign="middle">
<?php echo $this->session->flashdata('message'); ?>
</p>
</td></tr></table></td></tr></table>
</div>
<?php
	}
?>
<div id="pagecontent">
  <div id='addmenu'>
    <fieldset style="border:none">
    
    <div id="addnew">
      <div>
        <label for="cmenuname_vn"><?php echo $this->lang->line('m_menuname').'_<span class="sublang">'.$this->lang->line('vietnamese').'</span>'; ?></label>
        <input id="cmenuname_vn" name="menuname_vn" type="text" size="50" maxlength="100" value=""/>
      </div>
      <div>
        <label for="cmenuname"><?php echo $this->lang->line('m_menuname').'_<span class="sublang">'.$this->lang->line('english').'</span>'; ?></label>
        <input id="cmenuname" name="menuname" type="text" size="50" maxlength="50" value=""/>
      </div>
      <div>
        <label for="csort"><?php echo $this->lang->line('m_sort'); ?></label>
        <input id="csort" name="sort" type="text" size="5" maxlength="4" value=""/>
      </div>
    </div>
    <input type="hidden" name="id" value="" />
    <input type="hidden" name="component" value="com_article" />
    <input id="myoption" type="hidden" name="option" value="search_article" />
    <input type="hidden" name="myurl" value="<?php echo base_url().index_page().$this->uri->uri_string(); ?>" />
    <input type="hidden" name="task" value="" />
    <div class="toolbar"  align="center">
      <table width="100px" border="0" align="center" cellpadding="5">
        <tr>
          <td align="center"><a onclick="javascript: submitbutton('save')" href="#"><span class="icon-32-save" title="<?php echo $this->lang->line('save'); ?>"> </span><?php echo $this->lang->line('save'); ?></a></td>
          <td align="center"><a onclick="document.adminForm.reset()" href="#"><span class="icon-32-cancel" title="<?php echo $this->lang->line('reset'); ?>"> </span><?php echo $this->lang->line('reset'); ?></a></td>
        </tr>
      </table>
    </div>
  </fieldset>
  </div> 
</div>
<div id="listmenu" align="center" style="width:100%; padding-left:10px;"> 
<table width="90%" id="tablesorter-demo" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
  <thead>
  <tr>
    <th align="center" width="60%"><?php echo $this->lang->line('table_header_article_name'); ?></th>
	<th align="center" width="15%" ><?php echo $this->lang->line('table_header_date'); ?></th>
	<th align="center" width="15%" ><?php echo $this->lang->line('table_header_pageview'); ?></th>
    <th align="center" width="10%" class="{sorter: false}"><?php echo $this->lang->line('table_header_action'); ?></th>
  </tr>
  </thead>
  <tbody>
   <?php 
				for($i=0;$i<count($all_article);$i=$i+2)
				{
					echo "<tr><td style='padding-left:35px;'><p><span style='text-decoration:underline'>".$this->lang->line('vietnamese').":</span><span class='nameoftitle'>".$all_article[$i][2]."</span></p><p><span style='text-decoration:underline'>".$this->lang->line('english').":</span><span class='nameoftitle'>".$all_article[$i+1][2]."</span></p></td><td align='center'>".date('d-m-Y',strtotime($all_article[$i][3]))."</td><td align='center'>".$all_article[$i][1]."</td><td align='center'><a href='".base_url().index_page()."/adminpage/cpanel/show_edit_article/".$all_article[$i][0].".dkw'>".$this->lang->line('action_edit')."</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style='cursor:pointer' onclick='checkdelete(".$all_article[$i][0].")'>".$this->lang->line('action_delete')."</a></td></tr>";	
						/*echo "<li><a href='".base_url().$this->lang->line('seo_product')."/".$product_menu[$i][2]."'><span>"
.$product_menu[$i][1]."</span></a></li>";*/
				}
	?> 
  </tbody>
</table>
  </div> 
</div>
<script>

  $(document).ready(function(){
    $("#addmenu").hide();
	//$("img#vietnam").addClass('activelanguage');
    $("#add").click(function () {
	  //$("#addmenu").show('slow');
	  $('#addmenu').toggle(400); // First click should toggle to 'show'
      return false;

    });
  });

 $(document).ready(function() {  
  zebraRows('tbody tr:odd td', 'odd');  
  	$('tbody tr').hover(function(){  
		$(this).find('td').addClass('hovered');  
		}, function(){  
		$(this).find('td').removeClass('hovered');  
 	}); 
 });  
 function zebraRows(selector, className)  
	{  
	  $(selector).removeClass(className).addClass(className);  
	}  
</script>
<script type="text/javascript">
	$(document).ready(function() { 
    $("#tablesorter-demo").tablesorter({ 
        // pass the headers argument and assing a object 
        headers: { 
            // assign the third column (we start counting zero) 
            3: { 
                // disable it by setting the property sorter to false 
                sorter: false 
            } 
        } 
    }); 
});

function checkdelete(id)
{	
	var value = confirm("<?php echo $this->lang->line('meg_confirm') ?>");
	if (value==false)
	{
		return;
	}
	else
	{
		location.href='<?php echo base_url().index_page()."/adminpage/cpanel/delete_article/"; ?>'+id;
	}
}

</script>

<script>
function checkvalidate() 
{
	result=0;
/*	curr_pass=document.getElementById("currentpassword").value;
	new_pass=document.getElementById("newpassword").value;
	renew_pass=document.getElementById("renewpassword").value;
	if (curr_pass=="" || new_pass=="" || renew_pass=="")
	{
		document.getElementById("error_message").innerHTML="<?php echo $this->lang->line('f_all_field'); ?>";
	}
	else if (new_pass.length<8)
	{
		document.getElementById("error_message").innerHTML="<?php echo $this->lang->line('f_password_length'); ?>";
	}
	else if (new_pass!=renew_pass)
	{
		document.getElementById("error_message").innerHTML="<?php echo $this->lang->line('f_confirm_password'); ?>";
	}
	else if (document.getElementById("correctpass").value==0)
	{
		result=0;
	}
	else
	{
		result=1;
	}*/
	return 1;
}


$(document).ready(function() {

// create custom rule
	jQuery.validator.addMethod("greaterThanZero", function(value, element){
	    return this.optional(element) || (parseFloat(value) > 0);
		}, "* Amount must be greater than zero");
	
	//========================================
		
	// validate signup form on keyup and submit
/*	var validator = $("#adminForm").validate({
		rules: {
			email: {
				required: true,
				email: true, // Jquery test email
				remote: "emails.php"
			},
			cphone:{
				required: true, 
				number: true,  // only number
				digits: true,  // only number
				rangelength: [5, 12],
				greaterThanZero : true       //==== custom rule
			
			},
			dateformat: "required",
			terms: "required"
		},
		messages: {
			cphone: {
				required:"Enter your phone",
				digits:"Number please",
				rangelength: jQuery.format("Atleast {0} - {1} length"),
				greaterThanZero :" >0 please"     //==== custom rule
			},
			email: {
				required: "Please enter a valid email address",
				minlength: "Please enter a valid email address",
				remote: jQuery.format("{0} is already in use")
			},
			dateformat: "Choose your preferred dateformat",
			terms: " You must check this"
		},
});
*/	

	$("#cphone").focus(function() {
		//var firstname = $("#firstname").val();
		var cphone_vn = $("#cphone_vn").val();
		if(cphone_vn && !this.value) 
		{
			this.value = cphone_vn;
		}
	});
	$("#cemail").focus(function() {
		//var firstname = $("#firstname").val();
		var cemail_vn = $("#cemail_vn").val();
		if(cemail_vn && !this.value) 
		{
			this.value = cemail_vn;
		}
	});
	$("#cfax").focus(function() {
		//var firstname = $("#firstname").val();
		var cfax_vn = $("#cfax_vn").val();
		if(cfax_vn && !this.value) 
		{
			this.value = cfax_vn;
		}
	});
});

</script>
